package com.example.service.impl;

import com.example.util.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class LoginServiceImpl {

    @Autowired
    private RedisCache redisCache;


    public void saveToken(String token) {
        String userKey = this.getTokenKey(token);
        int expireTime = 1000;
        redisCache.setCacheObject(userKey, token, expireTime, TimeUnit.MINUTES);
    }

    public void deleteToken(String token) {
        boolean b = redisCache.deleteObject(token);
    }


    public String getTokenKey(String uuid)
    {
        return "login_tokens:" + uuid;
    }



}
